<?php
	$v_params = $this->getParams();
	$o_nomeAB = $v_params['nome_abreviado'];
	$listaGeralOS = $v_params[1];
	$lc = $v_params[0];
	$colors = new colorBlocks;
?>
<!DOCTYPE html>
<html lang="pt-br">
	<head>
		<base href="<?php echo SERVER_URL; ?>" />
		<meta charset="UTF-8">
		<title>TGV OS - Ordens de serviço</title>
        <link href="public_html/favicon.ico" rel="icon" type="image/x-icon" />
		<link rel="stylesheet" type="text/css" href="public_html/css/default.css" />
        <link rel="stylesheet" type="text/css" href="public_html/css/jquery-ui.css" />
        <link rel="stylesheet" type="text/css" href="public_html/css/forms.css" />
        <script src="public_html/js/jquery.js" ></script>
        <script src="public_html/js/modernizr.js" ></script>
        <script src="public_html/js/jquery-ui.js" ></script>
        <script src="public_html/js/timepicker.js" ></script>
        <script src="public_html/js/modalBox.js" ></script>
        <script src="public_html/js/updateBD.js" ></script>
	</head>
	<body>
		<div id="boxPrincipal">
			<?php 
				$menuAtivo = "./OS/listar";
				include('./views/template.php');
            ?>
			<div id="conteudo">
				<!-- INICIO DA PARTE EDITAVEL DE CODIGOS -->
                
                	<form id="formFiltro" style="float:left" name="filtroOS" method="get" action="OS/listar/">
                        <input type="hidden" name="c" value="id_cliente" />
                        <select name="v" required>
                        	<option value="">Selecione um cliente</option>
							<?php 
                                foreach($lc as $lco){
									$st = (@$_GET["v"] == $lco["id_cliente"]) ? ' selected' : '';
                                    echo '<option value="'.$lco["id_cliente"].'"'.$st.'>'.$lco["no_cliente"].
									'</option>';
                                }
                            ?>
                        </select>
                        <input type="submit" value="Filtrar" />
                        <input type="button" onClick="location.href='OS/listar'" value="Limpar" />
                    </form>
                  <div id="menuSuperior">
               	  <a href='#inserirOS' class='openBox btn_laranja' data-titulo="Nova ordem de serviço">Nova OS</a>
                    <a href='#' style="display:none" class='btn_laranja'>Buscar OS</a>
                </div>
                <hr class="clear">
				<div class="conteudoDinamico" align="center">
					<table class="lista" style="width:98%;">
						<thead>
                        <tr>
							<th>&nbsp;</th>
                            <th>Cliente</th>
                           	<th>Mês/Ano Referência</th>
                            <th>Planejado</th>
                            <th>Executado</th>
                            <th>Valor</th>
							<th>&nbsp;</th>
						</tr>
                        </thead>
                        <tbody>
                        <?php 
							foreach($listaGeralOS as $ls){ if($ls["id_os"]){ 
								$colors->getColor($ls["no_cliente"]);
						?>
						<tr>
                        	<td class="icon">
								<div style="background: <?php echo $colors->color; ?>">
									<?php echo $colors->colorChar; ?>
                                </div>
                            </td>
                            <td>
                            	<a title="Mostrar cliente" 
                                href="./clientes/listar#mostrarCliente-<?php echo $ls["id_cliente"] ?>">
									<?php echo $ls["no_cliente"] ?>
                               	</a>
							</td>
							<td>
								<?php echo substr($ls["dt_abertura_os"], 3, 7); ?>
                            </td>
                            <td>
								<?php echo $ls["nu_horas_planejadas"] . ' horas'; ?>
							</td>
                            <td>
								<?php echo $ls["tt_horas_os"] . ' horas'; ?>
							</td>
                            <td>
								<?php echo "R$ " .number_format($ls["vl_os"], 2, ',', '.');?>
							</td>
							<td>
								<a href="#mostrarOS-<?php echo $ls["id_os"] ?>" 
                                data-titulo="Ordem de Serviço &rArr; <?php echo $ls["no_os"] ?>" 
                                class="openBox btn_laranja" >Ver mais</a>
							</td>
						</tr>
                        <?php }else { echo '<td colspan="7">Nenhuma OS cadastrada na aplicação</td>'; } } ?>
                        </tbody>
                        <tfoot class="nav">
                            <tr>
                                <td colspan="7">
                                    <div class="pagination"></div>
                                    <div class="paginationTitle">Página</div>
                                    <div class="selectPerPage"></div>
                                    <div class="status"></div>
                                </td>
                            </tr>
                        </tfoot>
					</table>
				</div>
                <div id="modalBox">
                	<ul class="listaHorizontal">
                    	<li class="tituloModal destaqueTexto">Titulo da Janela</li>
                        <li><a href="#" class="closeBox destaqueTexto">X</a></li>
                    </ul>
                    <div id="conteudoModal">
     					<img src="public_html/imagens/load.gif" class="load" />
					</div>
                </div>
				<!-- FIM DA PARTE EDITAVEL DE CODIGOS -->
			</div>
		</div>
	</body>
</html>